<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>vue1</title>
        <script src="../js/vue.js"></script>
        <script src="../js/vuex.js"></script>
    </head>
    <body>
        <div id="app">
            <grandfather></grandfather>
        </div>
        <template id="grandfather">
            <div>
                我是爷爷 --- {{this.$store.state.msg}}---{{this.$store.state.count}}
                <button @click="change">aaa</button>
                <p>---</p>
                <father></father>
            </div>
        </template>
        <template id="father">
            <div>
                我是粑粑 --- {{this.$store.state.msg}}
                <p>---</p>
                <son></son>
            </div>
        </template>
        <template id="son">
            <div>
                我是儿子 --- {{this.$store.state.msg}}
            </div>
        </template>
        <script>
            
            const store = new Vuex.Store({
                // state 用于保存共享数据
                state: {
                    count: 0,
                    msg:"啊啊啊啊啊"
                },
            })
            Vue.component("grandfather",{
                template:"#grandfather",
                store:store,
                methods: {
                    change(){
                        this.$store.state.count = 10
                    }
                },
                components:{
                    "father":{
                        template:"#father",
                        components:{
                            "son":{
                                template:"#son"
                            }
                        }
                    },
                    
                }
            })
            let vue = new Vue({
        // 告诉vue的实例对象，将来需要控制界面上的那个区域
                el:'#app',
                data:{
                    name:"内容1"
                }
            });
        </script>
    </body>
</html>